from ultralytics import YOLO


if __name__ == '__main__':
    # 加载一个模型
    # model = YOLO('yolov8n.pt')  # 从YAML建立一个新模型
    # # 训练模型
    # results = model.train(
    #     data="./Myvoc.yaml",
    #     device='0',
    #     epochs=5,
    #     batch=4,
    #     verbose=False,
    #     imgsz=640)

    model = YOLO('yolov8s.pt')
    ##三个权重

    ##训练次数等在utlralytics/default.yaml
    model.train(data="./Myvoc.yaml")








# yolo = YOLO('./yolov8n.pt',task='detect')
#
# results = yolo(source="./images/1.mp4",save=True,conf=0.05,show=True,stream=True)
# # result1 = result[0]
# # print(result1)
# for r in results:
#         boxes = r.boxes  # Boxes object for bbox outputs
#         masks = r.masks  # Masks object for segment masks outputs
#         probs = r.probs  # Class probabilities for classification outputs
#         # print(boxes)

# import matplotlib.pyplot as plt
# %matplotlib inline
# plt.show(result[0].plot())q


# cls: tensor([2., 2., 2., 2., 2., 7., 2., 2., 6., 7., 2., 2.], device='cuda:0')
# conf: tensor([0.6940, 0.6778, 0.5451, 0.4738, 0.2153, 0.2022, 0.1394, 0.1052, 0.0938, 0.0884, 0.0826, 0.0607], device='cuda:0')
# data: tensor([[8.0267e+02, 3.9326e+02, 8.5924e+02, 4.3138e+02, 6.9399e-01, 2.0000e+00],
#         [5.1587e+02, 3.8278e+02, 5.6304e+02, 4.2635e+02, 6.7776e-01, 2.0000e+00],
#         [3.8111e+02, 3.9790e+02, 4.4346e+02, 4.4632e+02, 5.4511e-01, 2.0000e+00],
#         [5.2733e+02, 3.1790e+02, 5.5844e+02, 3.3953e+02, 4.7377e-01, 2.0000e+00],
#         [3.4180e-01, 2.9152e+02, 2.9937e+01, 3.1426e+02, 2.1529e-01, 2.0000e+00],
#         [7.2083e+02, 2.7416e+02, 7.5656e+02, 3.1638e+02, 2.0221e-01, 7.0000e+00],
#         [8.0296e+02, 3.9244e+02, 8.7872e+02, 4.3406e+02, 1.3937e-01, 2.0000e+00],
#         [5.9581e+02, 3.0486e+02, 6.2082e+02, 3.2552e+02, 1.0521e-01, 2.0000e+00],
#         [7.1963e+02, 2.7370e+02, 7.6004e+02, 3.1640e+02, 9.3773e-02, 6.0000e+00],
#         [8.3268e+02, 2.5844e+02, 8.7757e+02, 3.2469e+02, 8.8450e-02, 7.0000e+00],
#         [5.1420e+02, 3.8287e+02, 5.8665e+02, 4.2629e+02, 8.2577e-02, 2.0000e+00],
#         [5.5042e+02, 3.0222e+02, 5.9476e+02, 3.3479e+02, 6.0678e-02, 2.0000e+00]], device='cuda:0')
# id: None
# is_track: False
# orig_shape: (720, 1280)
# shape: torch.Size([12, 6])
# xywh: tensor([[830.9510, 412.3218,  56.5693,  38.1165],
#         [539.4507, 404.5645,  47.1694,  43.5775],
#         [412.2874, 422.1125,  62.3527,  48.4219],
#         [542.8868, 328.7146,  31.1057,  21.6252],
#         [ 15.1393, 302.8913,  29.5951,  22.7383],
#         [738.6941, 295.2711,  35.7278,  42.2129],
#         [840.8425, 413.2487,  75.7617,  41.6241],
#         [608.3149, 315.1918,  25.0105,  20.6570],
#         [739.8338, 295.0495,  40.4070,  42.7024],
#         [855.1241, 291.5648,  44.8884,  66.2443],
#         [550.4250, 404.5792,  72.4473,  43.4133],
#         [572.5909, 318.5085,  44.3427,  32.5695]], device='cuda:0')
# xywhn: tensor([[0.6492, 0.5727, 0.0442, 0.0529],
#         [0.4214, 0.5619, 0.0369, 0.0605],
#         [0.3221, 0.5863, 0.0487, 0.0673],
#         [0.4241, 0.4565, 0.0243, 0.0300],
#         [0.0118, 0.4207, 0.0231, 0.0316],
#         [0.5771, 0.4101, 0.0279, 0.0586],
#         [0.6569, 0.5740, 0.0592, 0.0578],
#         [0.4752, 0.4378, 0.0195, 0.0287],
#         [0.5780, 0.4098, 0.0316, 0.0593],
#         [0.6681, 0.4050, 0.0351, 0.0920],
#         [0.4300, 0.5619, 0.0566, 0.0603],
#         [0.4473, 0.4424, 0.0346, 0.0452]], device='cuda:0')
# xyxy: tensor([[8.0267e+02, 3.9326e+02, 8.5924e+02, 4.3138e+02],
#         [5.1587e+02, 3.8278e+02, 5.6304e+02, 4.2635e+02],
#         [3.8111e+02, 3.9790e+02, 4.4346e+02, 4.4632e+02],
#         [5.2733e+02, 3.1790e+02, 5.5844e+02, 3.3953e+02],
#         [3.4180e-01, 2.9152e+02, 2.9937e+01, 3.1426e+02],
#         [7.2083e+02, 2.7416e+02, 7.5656e+02, 3.1638e+02],
#         [8.0296e+02, 3.9244e+02, 8.7872e+02, 4.3406e+02],
#         [5.9581e+02, 3.0486e+02, 6.2082e+02, 3.2552e+02],
#         [7.1963e+02, 2.7370e+02, 7.6004e+02, 3.1640e+02],
#         [8.3268e+02, 2.5844e+02, 8.7757e+02, 3.2469e+02],
#         [5.1420e+02, 3.8287e+02, 5.8665e+02, 4.2629e+02],
#         [5.5042e+02, 3.0222e+02, 5.9476e+02, 3.3479e+02]], device='cuda:0')
# xyxyn: tensor([[6.2708e-01, 5.4620e-01, 6.7128e-01, 5.9914e-01],
#         [4.0302e-01, 5.3163e-01, 4.3987e-01, 5.9216e-01],
#         [2.9774e-01, 5.5264e-01, 3.4646e-01, 6.1989e-01],
#         [4.1198e-01, 4.4153e-01, 4.3628e-01, 4.7157e-01],
#         [2.6703e-04, 4.0489e-01, 2.3388e-02, 4.3647e-01],
#         [5.6315e-01, 3.8078e-01, 5.9106e-01, 4.3941e-01],
#         [6.2731e-01, 5.4505e-01, 6.8650e-01, 6.0286e-01],
#         [4.6548e-01, 4.2342e-01, 4.8502e-01, 4.5211e-01],
#         [5.6221e-01, 3.8014e-01, 5.9378e-01, 4.3945e-01],
#         [6.5053e-01, 3.5895e-01, 6.8560e-01, 4.5095e-01],
#         [4.0172e-01, 5.3177e-01, 4.5832e-01, 5.9206e-01],
#         [4.3002e-01, 4.1976e-01, 4.6466e-01, 4.6499e-01]], device='cuda:0')
# video 1/1 (1/5396) D:\wangsenli\code\ultralytics-main\images\1.mp4: 384x640 9 cars, 1 train, 2 trucks, 45.8ms